// client/Client控制器
define('clientClientController', ['angular','jquery'], function (angular,$) {
    var module = angular.module('controllers');
    module.controller('clientClientController', ['$scope','$rootScope','$filter','$location','$route','businessServers', function ($scope,$rootScope,$filter,$location,$route,businessServers) {
    	$scope.formData={
            business_type:1
        };
        $scope.moreInfo=false;
        $scope.clientForm=function(valid,path){
            if(valid){
                if(!$scope.moreInfo){
                    $scope.moreInfo=true;
                }else{
                    $scope.formData = $filter('simplifyJsonFilter')($scope.formData);
                    console.log($scope.formData);
                    if(!$scope.formData.consultant_id){
                        $scope.formData.business_type=2;
                    }
                    businessServers.addBusiness($scope.formData).then(function(data) {
                        if(data){
                            $location.path(path);
                        }else{
                            alert("添加失败");
                        }
                    });
                }
            }else{
                alert("请填写正确填写相关信息");
            }
        };
    }]);
});